<template>
	<view>
		<view style="background: #409EFF;height:600upx">
			<view style="height:250upx;"></view>
			<view class="form-title">百居易登录系统</view>
		</view>
		<view class="form">
			<view class="form-item">
				<input placeholder="请输入登录账号" v-model="form.username"/>
			</view>
			<view class="form-item">
				<input placeholder="请输入登录密码" type="password" v-model="form.pwd"/>
			</view>
			<view class="form-item">
				<button @tap="login()">登录</button>
			</view>
			<view class="reg-box">
				<text @tap="toReg()">没有账号？立即注册</text>
				<!-- <text>忘记密码</text> -->
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				form : {
					username : '',
					pwd :''
				}
			}
		},
		onLoad() {
			/* if(uni.getStorageInfoSync('username') && uni.getStorageInfoSync('pwd')){
				this.form.username = uni.setStorageSync('username');
				this.form.pwd = uni.getStorageInfoSync('pwd');
				this.login();
			} */
		},
		methods:{
			toReg(){
				uni.navigateTo({
					url:'reg'
				})
			},
			login(){
				if(!this.form.username)return this.toasts('用户名不能为空');
				if(!this.form.pwd)return this.toasts('密码不能为空');
				this.ajax('Login/logindo',{
					data:this.form,
					success:(res) => {
						res = res.data;
						this.toasts(res.info);
						if(res.status){
							uni.setStorageSync('username',this.form.username);
							uni.setStorageSync('pwd',this.form.pwd);
							setTimeout(()=>{
								uni.switchTab({
									url:"../index/index"
								})
							},2000)
						}
					}
				})
			}
		}
		
	}
</script>

<style>
	.form{position:absolute;width: calc(85% - 40upx);left:7.5%;top:400upx;background: #FFFFFF;padding:20upx;border-radius: 10upx;box-shadow: 0 1px 1px rgba(26, 26, 26, .2);}
	.form-item{width: calc(100% - 40upx);margin:20upx;margin-top: 40upx;}
	.form-item input{width: 100%;height:80upx;border-bottom:1upx solid #aaa;border-radius: 10upx;font-size: 30upx;padding-left: 20upx;color:#AAAAAA}
	.form-item button{height:80upx;line-height: 80upx;background: #409EFF;color:#FFFFFF;margin-top: 20upx;}
	.form-title{text-align: center;font-size: 50upx;margin-bottom: 80upx;font-weight: 800;}
	.reg-box{overflow: hidden;margin-top: 20upx;}
	.reg-box text{font-size: 25upx;float:left;color:#666;}
	.reg-box text:last-child{float:right}
</style>
